import { axiosDelete, getNestApiData } from "../../../tools/HttpClient";
export async function templateListApi() {
    try {
        const res = await getNestApiData("/template/list", "get");
        if (res.ok) {
            return Promise.resolve({
                data: res.data,
                success: true,
            });
        }
        return Promise.resolve({
            data: res.data,
            success: false,
        });
    }
    catch (error) {
        console.error(error);
        return Promise.resolve({
            data: "接口/template/list,请求失败！",
            success: false,
        });
    }
}
export async function deleteteMplate(params) {
    try {
        const res = await axiosDelete("/template?q=1", params);
        if (res.data.ok) {
            return Promise.resolve({
                data: res.data,
                success: true,
            });
        }
        return Promise.resolve({
            data: res.data,
            success: false,
        });
    }
    catch (error) {
        console.error(error);
        return Promise.resolve({
            data: "接口/template/list,请求失败！",
            success: false,
        });
    }
}
export async function templateImport(params) {
    try {
        const res = await getNestApiData("/template/import", "post", params);
        if (res.ok) {
            return Promise.resolve({
                data: res.data,
                success: true,
                msg: "",
            });
        }
        return Promise.resolve({
            data: res.data,
            success: false,
            msg: res.msg,
        });
    }
    catch (error) {
        return Promise.resolve({
            data: "接口/template/list,请求失败！",
            success: false,
            msg: "接口/template/list,请求失败！",
        });
    }
}
export async function templateImportTB(params) {
    try {
        const res = await getNestApiData("/template/exportDataTamplate", "post", params);
        if (res.ok) {
            return Promise.resolve({
                data: res.data,
                success: true,
            });
        }
        return Promise.resolve({
            data: res.data,
            success: false,
        });
    }
    catch (error) {
        return Promise.resolve({
            data: "接口/template/list,请求失败！",
            success: false,
        });
    }
}
export async function templateExport(params) {
    try {
        const res = await getNestApiData("/template/export", "post", params);
        if (res.ok) {
            return Promise.resolve({
                data: res.data,
                success: true,
            });
        }
        return Promise.resolve({
            data: res.data,
            success: false,
        });
    }
    catch (error) {
        return Promise.resolve({
            data: "接口/template/list,请求失败！",
            success: false,
        });
    }
}
// 判断是否重名
export async function queryTemplateNameIfExist(params) {
    try {
        const res = await getNestApiData(`/template/queryTemplateNameIfExist?templateName=${params.templateName}&TemplateType=${params.TemplateType}`, "get");
        if (res.ok) {
            return Promise.resolve({
                data: res.data,
                success: true,
            });
        }
        return Promise.resolve({
            data: res.data,
            success: false,
        });
    }
    catch (error) {
        return Promise.resolve({
            data: "接口/template/list,请求失败！",
            success: false,
        });
    }
}
// 导出判断是否重名
export async function queryFileIfExistInDisk(params) {
    try {
        const res = await getNestApiData(`/template/queryFileIfExistInDisk?templateName=${params.templateName}&targetPath=${params.targetPath}`, "get");
        if (res.ok) {
            return Promise.resolve({
                data: res.data,
                success: true,
            });
        }
        return Promise.resolve({
            data: res.data,
            success: false,
        });
    }
    catch (error) {
        return Promise.resolve({
            data: "接口/template/list,请求失败！",
            success: false,
        });
    }
}
// 修改名称
export async function templateRename(params) {
    try {
        const res = await getNestApiData("/template/rename", "post", params);
        if (res.ok) {
            return Promise.resolve({
                data: res.data,
                success: true,
            });
        }
        return Promise.resolve({
            data: res,
            success: false,
        });
    }
    catch (error) {
        return Promise.resolve({
            data: "接口/template/list,请求失败！",
            success: false,
        });
    }
}
